<template>
  <el-col>
    <el-select v-model="deviceType" placeholder="请选择设备类型">
      <el-option label="全部类型" value=""></el-option>
      <el-option v-for="(item, i) in firstArr" :key="i" :value="item.paramName" :label="item.paramName"></el-option>
    </el-select>
  </el-col>
</template>

<script>
export default {
  name: 'sceneSelect',
  props: ['selectModel'],
  data () {
    return {
      tempPromise: {},
      firstArr: [],
      deviceType: this.selectModel
    }
  },
  mounted: function () {
    this.tempPromise = this.getList()
  },
  watch: {
    selectModel (val) {
      this.tempPromise.then(resolve => {
        this.deviceType = val
      })
    },
    deviceType (val) {
      this.$emit('onDeviceChange', val)
    }
  },
  methods: {
    getList () {
      return new Promise(resolve => {
        let url = this.$base.getUrl('getEquipmentType')
        let params = {
          url: url
        }
        this.$store.dispatch('getForm', params).then((res) => {
          this.firstArr = res
          resolve()
        })
      })
    }
  }
}
</script>

<style scoped>

</style>
